﻿using System.Xml;
using System.Xml.Serialization;
using System;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml.Schema;

namespace ScormModel
{
    [Serializable()]
    public class ControlMode
    {
        private string _choice ;
        private string _choiceExit ;
        private string _flow ;
        private string _forwardOnly ;
        private string _useCurrentAttemptObjectiveInfo ;
        private string _useCurrentAttemptProgressInfo ;
         [NonSerialized]
        private XmlNode _controlModeContent;
        [XmlAttribute("choice")]
        public string Choice
        {
            get { return this._choice; }
            set { this._choice = value; }
        }
        [XmlAttribute("choiceExit")]
        public string ChoiceExit
        {
            get { return this._choiceExit; }
            set { this._choiceExit = value; }
        }
        [XmlAttribute("flow")]
        public string Flow
        {
            get { return this._flow; }
            set { this._flow = value; }
        }
        [XmlAttribute("forwardOnly")]
        public string ForwardOnly
        {
            get { return this._forwardOnly; }
            set { this._forwardOnly = value; }
        }
        [XmlAttribute("useCurrentAttemptObjectiveInfo")]
        public string UseCurrentAttemptObjectiveInfo
        {
            get { return this._useCurrentAttemptObjectiveInfo; }
            set { this._useCurrentAttemptObjectiveInfo = value; }
        }
        [XmlAttribute("useCurrentAttemptProgressInfo")]
        public string UseCurrentAttemptProgressInfo
        {
            get { return this._useCurrentAttemptProgressInfo; }
            set { this._useCurrentAttemptProgressInfo = value; }
        }
        
        [XmlIgnoreAttribute]
        public XmlNode ControlModeContent
        {
            get { return this._controlModeContent; }
            set { this._controlModeContent = value; }
        }
        public void buildControlMode()
        {
            if (_controlModeContent != null)
            {
                XmlAttributeCollection attList = _controlModeContent.Attributes;
                if (attList.GetNamedItem("flow") != null)
                {
                    _flow = ((XmlAttribute)attList.GetNamedItem("flow")).Value;
                }
                if (attList.GetNamedItem("choice") != null)
                {
                    _choice = ((XmlAttribute)attList.GetNamedItem("choice")).Value;
                }
                if (attList.GetNamedItem("choiceExit") != null)
                {
                    _choiceExit = ((XmlAttribute)attList.GetNamedItem("choiceExit")).Value;
                }
                if (attList.GetNamedItem("forwardOnly") != null)
                {
                    _forwardOnly = ((XmlAttribute)attList.GetNamedItem("forwardOnly")).Value;
                }
            }
        }
    }
}
